package com.bristua.common.biz;

import com.bristua.common.bean.CommonQueryParams;
import com.bristua.common.bean.PageBean;
import com.bristua.common.dao.TFeedbackMapper;
import com.bristua.common.model.TFeedback;
import com.bristua.common.model.condition.TFeedbackExample;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import javax.annotation.Resource;

/**
 * Created by Administrator on 2019/5/1.
 */
@Service
public class FeedbackBiz {

    @Resource
    private TFeedbackMapper tFeedbackMapper;

    public PageBean queryFeedback(CommonQueryParams commonQueryParams){
        TFeedbackExample tFeedbackExample = new TFeedbackExample();
        TFeedbackExample.Criteria criteria = tFeedbackExample.createCriteria();

        if(!StringUtils.isEmpty(commonQueryParams.getStartTime())){
            criteria.andCreateTimeGreaterThan(commonQueryParams.getStartTime()+" 00:00:00");
        }

        if(!StringUtils.isEmpty(commonQueryParams.getEndTime())){
            criteria.andCreateTimeLessThan(commonQueryParams.getEndTime()+" 23:59:59");
        }
        Page<TFeedback> objects = PageHelper.startPage(commonQueryParams.getPageNo(),commonQueryParams.getPageSize());
        tFeedbackMapper.selectByExample(tFeedbackExample);
        PageBean data = new PageBean<>(objects);
        return data;

    }


}
